package com.stm.basicData.service.impl;

import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stm.basicData.mapper.ToolsFactoryMapper;
import com.stm.basicData.domain.ToolsFactory;
import com.stm.basicData.service.IToolsFactoryService;
import com.stm.common.annotation.DataScope;
import com.stm.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;

/**
 * 生产厂家 服务层实现
 * 
 * @author wyc
 * @date 2019-04-04
 */
@Service
public class ToolsFactoryServiceImpl implements IToolsFactoryService 
{
	@Autowired
	private ToolsFactoryMapper toolsFactoryMapper;

	/**
     * 查询生产厂家信息
     * 
     * @param id 生产厂家ID
     * @return 生产厂家信息
     */
    @Override
	public ToolsFactory selectToolsFactoryById(String id)
	{
	    return toolsFactoryMapper.selectToolsFactoryById(id);
	}
	
	/**
     * 查询生产厂家列表
     * 
     * @param toolsFactory 生产厂家信息
     * @return 生产厂家集合
     */
	@Override
	@DataScope(tableAlias = "b2")
	public List<ToolsFactory> selectToolsFactoryList(ToolsFactory toolsFactory)
	{
	    return toolsFactoryMapper.selectToolsFactoryList(toolsFactory);
	}
	
    /**
     * 新增生产厂家
     * 
     * @param toolsFactory 生产厂家信息
     * @return 结果
     */
	@Override
	@Transactional
	public int insertToolsFactory(ToolsFactory toolsFactory)
	{
		UUID uuid = UUID.randomUUID();
		toolsFactory.setId(uuid.toString());
		toolsFactory.setStatus("1");
		toolsFactory.setCreateDate(new Date());
	    return toolsFactoryMapper.insertToolsFactory(toolsFactory);
	}
	
	/**
     * 修改生产厂家
     * 
     * @param toolsFactory 生产厂家信息
     * @return 结果
     */
	@Override
	@Transactional
	public int updateToolsFactory(ToolsFactory toolsFactory)
	{
		toolsFactory.setUpdateDate(new Date());
	    return toolsFactoryMapper.updateToolsFactory(toolsFactory);
	}

	/**
     * 删除生产厂家对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteToolsFactoryByIds(String ids)
	{
		return toolsFactoryMapper.deleteToolsFactoryByIds(Convert.toStrArray(ids));
	}

	/**
	 * 
	 * @Description 根据厂家名称查询厂家信息
	 * @CreateTime 2019年4月29日 上午8:55:10
	 * @CreateBy 林龙
	 * @param factoryName
	 * @return
	 */
	@Override
	public ToolsFactory selectByFactoryName(String factoryName) {
		return toolsFactoryMapper.selectByFactoryName(factoryName);
	}
	
}
